package cn.jhg.account.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {
	
	private final static Logger log = LoggerFactory.getLogger(LogAspect.class);
	
	@Pointcut("@annotation(cn.jhg.account.aspect.LogDefine)")
	private void cut(){}

	
	@Around(value="cut()&&@annotation(logDefine)")
	public void advice (ProceedingJoinPoint joinPoint, LogDefine logDefine){
		log.info("around log begins...");
		
		try{
			String value = logDefine.value();
			log.info("value=" + value);
			joinPoint.proceed();
		}
		catch (Throwable e){
			e.printStackTrace();
			log.error(e.getMessage());
		}
		
		
		
		
		log.info("around log ends...");
	}
}
